<template>
  <el-dialog title="开挖方式信息录入" :visible.sync="dialogVisible" width="30%" :before-close="handleClose">
    <el-form :inline="true" :model="etype" label-width="100px" class="demo-form-inline">
      <el-form-item label="开挖方式">
        <el-input v-model="etype.eName"></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="create">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import api from '../../../api'
import qs from 'qs'
export default {
  data() {
    return {
      dialogVisible: false,
      //项目信息
      tunnelList: [],
      eTypeList: [],
      etype: {
        eName: '',
      }
    }
  },
  mounted() {
    this.$bus.$on('onAddtest', (flag) => {
      this.dialogVisible = flag
    })
  },
  methods: {
    handleClose(done) {
      this.$confirm('确认关闭？')
        .then((_) => {
          done()
        })
        .catch((_) => {})
    },
    create() {
      api
        .etypesave(qs.stringify(this.etype))
        .then((res) => {
          if (res.data.code == 2001) {
            this.$message({
              type: 'success',
              message: '添加成功!'
            })
            this.dialogVisible = false
            this.$bus.$emit('onRefreshEtype', true)
          } else {
            this.$message({
              type: 'fail',
              message: res.data.message
            })
            console.log(res.data.message)
          }
        })
        .catch((err) => {})
    },

    onSubmit() {
      console.log('submit!')
    }
  }
}
</script>

<style>
</style>